<?php
/**
 * 描述
 * Created by Paco
 * Date: 2018/10/7 Time: 14:38
 */

namespace App\Http\Controllers\Admin\Order;


use App\Http\Request\Order\OrderStore;
use App\Repositories\Order\OrderRepository;
use Illuminate\Http\Request;

class OrderController
{
    private $order;

    public function __construct(OrderRepository $order)
    {
        $this->order = $order;
    }

    /**
     *
     * 订单列表
     * author Paco
     * createTime 2018/11/12 16:22
     * @param Request $request
     * @return \Illuminate\Http\JsonResponse|mixed
     */
    public function orders(Request $request)
    {
        return $this->order->orders($request->all());
    }

    /**
     *
     * 订单详情
     * author Paco
     * createTime 2018/11/12 16:22
     * @param $order_number
     * @return \Illuminate\Http\JsonResponse|mixed
     */
    public function show($order_number)
    {
        return $this->order->show($order_number);
    }

    /**
     *
     * 创建订单
     * author Paco
     * createTime 2018/11/12 16:22
     * @param OrderStore $order
     * @param Request $request
     * @return \Illuminate\Http\JsonResponse|mixed
     * @throws \Illuminate\Validation\ValidationException
     */
    public function store(OrderStore $order, Request $request)
    {
        $params = $order->validated($request);
        return $this->order->addOrder($params);
    }

    /**
     *
     * 更新订单
     * author Paco
     * createTime 2018/11/12 16:23
     * @param OrderStore $order
     * @param Request $request
     * @return \Illuminate\Http\JsonResponse|mixed
     * @throws \Illuminate\Validation\ValidationException
     */
    public function save(OrderStore $order, Request $request)
    {
        $params = $order->validated($request);
        return $this->order->addOrder($params);
    }

    /**
     *
     * 删除订单
     * author Paco
     * createTime 2018/11/12 16:23
     * @param OrderStore $order
     * @param Request $request
     * @return \Illuminate\Http\JsonResponse
     * @throws \Illuminate\Validation\ValidationException
     */
    public function del(OrderStore $order, Request $request)
    {
        $params = $order->validated($request);
        return $this->order->delOrder($params);
    }
}